//index.js
//获取应用实例
const app = getApp()
import {
  login
} from "../../api/user"
Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  login() {
    return new Promise(resolve => {
      login({
        loginType: 1,
        value: app.globalData.openid
      }).then(res => {
        resolve(res);
      })
    })

  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
   
  },
  rGetUserinfo: function (e) {
    this.login().then(res => {
      wx.setStorageSync(
        'token',
        res.data.access_token
      )
      app.pushUserInfo()
    })
  }
})